<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<style>
  .TopBox {
    width: 300px;
    display: flex;
    justify-content: space-around;
    background-color: #f5f5f5;
    padding: 3px;
  }

  .zxcv {
    padding: 5px;
  }
</style>

<body>
  <div id="app"></div>
  <div id="mark"></div>
</body>
<!-- 引入 js 文件 -->
<!-- React 核心的交互代码 -->
<script src="./node_modules//react/umd/react.development.js"></script>
<!-- React dom 渲染的核心代码 -->
<script src="./node_modules/react-dom/umd/react-dom.development.js"></script>
<!-- 导入 Babel 插件，作用是将高版本的 JSX 语法进行低版本兼容 -->
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

<script type="text/babel">

  class Com1 extends React.Component {
    constructor(props){
      super(props);
      this.state = {
        show:false,
        styleBot:{
          color:'#fff',
          backgroundColor:'limegreen',
          border: 'none'
        },
        styleText:{
          color:'red',
          display:'block',
          fontSize: '20px',
          fontWeight: 'bolder'
          
        }
      }
      // 绑定this
      this.clcikAction = this.clcikAction.bind(this);
    }
    clcikAction(){
      this.setState(state=>{
        return{
          show: !state.show,
          styleText:{
            ...state.styleText,
            
          }display:state.styleText.display == "block" ? "none":"block"
        }
      })
    }
    render(){
      return (
        <div>
          {this.state.show ? <h2>这是一个 H2 标签</h2>:null}
          <p style={this.state.styleText}>这是通过样式控制的标签</p>
          <button style={this.state.styleBot} onClick={this.clcikAction}>显示&隐藏</button>
        </div>
      )
    }
  }
  class TapBox extends React.Component {

    render() {
      let kinds=[
        {tatle:"商品"},
        {tatle:"评价"},
        {tatle:"详情"},
        {tatle:"推荐"},
      ]
      return (
        <div className="TopBox">
          {kinds.map((item,index)=><div className="zxcv" key={index}>{item.tatle}</div>)}
          <div class="line"></div>

        </div>
      )
    }
    
  }
  ReactDOM.render(<Com1/>,document.querySelector('#app'));
  ReactDOM.render(<TapBox/>,document.querySelector('#mark'));
</script>

</html>